(function (window, $, undefined) {
  'use strict';

  main(function () {

    var $tableCarColor = $('#table-carColor');
    util.jqGrid($tableCarColor, {
      url: '/json/test.json',
      datatype: 'json',
      autowidth: true,
      height: $(window).height() - 350,
      multiselect: true,
      multiboxonly: true,
      // shrinkToFit: false,
      colModel: [
        { name: '_id', key: true, hidden: true },
        { label: 'ID', name: '', width: 50 },
        { label: '车辆品牌', name: '', width: 150 },
        { label: '车辆型号', name: '', width: 120 },
        { label: '车辆颜色', name: '', width: 80 },
        { label: '状态', name: '', width: 80 },
        { label: '录入时间', name: '', width: 110 }
      ],
      pager: '#pager-carColor'
    });

    laydate.render({
      elem: '#createDate' //指定元素
    });

    // 新增操作
    $('#btn-add').click(function () {
      $('#layer-color-add').find(':input').removeAttr('disabled');
      util.layerOpen({
        title: '新增车辆颜色',
        content: $('#layer-color-add'),
        btn: ['取消', '确定'],
        cancel: function (index) {
          layer.confirm('确定退出当前页面？', {
            btn: ['确定', '再想一想'],
            yes: function (idx) {
              layer.close(index);
              layer.close(idx);
            }
          });
          return false;
        }
      });
    });

    // 修改操作
    $('#btn-edit').click(util.oneCheck($tableCarColor, function (id) {
      $('#layer-color-edit').find(':input').removeAttr('disabled');
      util.layerOpen({
        title: '修改车辆颜色',
        content: $('#layer-color-edit'),
        cancel: function (index) {
          layer.confirm('确定退出当前页面？', {
            btn: ['确定', '再想一想'],
            yes: function (idx) {
              layer.close(index);
              layer.close(idx);
            }
          });
          return false;
        }
      });
    }));



  });


})(window, jQuery);
